Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
nativescript-webworkers
Advanced tools
A WebWorker (thread) NativeScript module for Android and iOS
NativeScript WebWorkers (threads) for Android and iOS This is really only useful if you need to access a hidden WebView now; NativeScript has internal support for WebWorkers for a long time now.
This is released under the MIT License, meaning you are free to include this in any type of program -- However for entities that need a support contract, changes, enhancements and/or a commercial license please contact me at http://nativescript.tools.
I also do contract work; so if you have a module you want built for NativeScript (or any other software projects) feel free to contact me nathan@master-technology.com.
v2.00 No longer attempts to assign the global Worker object; NativeScript has Native WebWorker support for a long time now.
Please note The WebWorker environment is a LIMITED JavaScript shell. It does have AJAX/HTTP(s) ability; but it does NOT have any access to any of the NativeScript api. It also does not have any access to the Native iOS or Android api's. It is strictly a JS thread. In addition at this moment "ImportScripts" has not been implemented. It should be fairly easy to implement; and if anyone wants to do a pull request to implement this; I'd be happy to add it to the code that gets injected into the environment.
If the device has more than one CPU; the Worker threads should not impact the main NativeScript thread. However, if the device only has one CPU; and depending on how busy you make the worker, it will impact the primary NativeScript thread.
Run tns plugin add nativescript-webworkers
in your ROOT directory of your project.
To use the module you must first require()
it:
const WebWorker = require( 'nativescript-webworkers' );
const myWorker = new WebWorker('~/web.worker.js'); // i.e. using the WebWorker variable returned by the require statement.
~/.../somescript.js
or full path /..../somescript.js
).HTML
- which allows you to pass in your own HTML file
.script
- which allows you to pass in your own javascript code
.baseURL
, otherwise defaults to the proper baseURL.####.onmessage(data) This will have the JSON object that was sent from the worker
####.onerror This will have any errors that occurred (this may be unreliable; as not all errors can be tracked properly)
####.onready
This is fired when the webworker environment is ready to go.
This is NOT a standard webworker function
This allows you to send some JS into the environment. This is NOT a standard webworker function
####.postMessage(data) This posts the message into the webworker environment ####.terminate() This terminates the webworker environment; after this is ran; DO NOT attempt to continue doing anything on this webworker.
####onmessage(data) The function that gets any messages from the NativeScript environment
####onready() This function will get called if it exists once the webworker is able to communicate with the NativeScript host. This is NOT a standard webworker function
####postMessage(data) The function you use to send message back to the NativeScript environment
####close() Terminates this environment
##Example:
const WebWorker = require( 'nativescript-webworkers' );
var myWorker = new WebWorker('~/test.worker.js');
myWorker.onmessage = function(m) { console.log("Webworker said:", m); };
myWorker.postMessage("Hello");
onmessage = function(m) {
console.log("NativeScript said" + m);
};
onready = function() {
postMessage("Hi");
};
FAQs
A WebWorker (thread) NativeScript module for Android and iOS
The npm package nativescript-webworkers receives a total of 3 weekly downloads. As such, nativescript-webworkers popularity was classified as not popular.
We found that nativescript-webworkers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.